#pragma once
#include "stdafx.h"

#include "../MyUtils/ISingleton.h"
#include "../MyUtils/OSUtils.h"
#include "../MyUtils/StringUtils.h"

#define NULL_RETURN(p) if(!(p)) return;

/*
#include <Shlwapi.h>
#pragma comment(lib,"shlwapi.lib")

namespace std
{
#ifdef UNICODE
	typedef wstring TString;
#else
	typedef string TString;
#endif
}



class ViewerUtils
{
public:
	static std::TString IntToString(int val)
	{
#ifdef UNICODE
		return std::to_wstring(val);
#else
		return std::to_string(val);
#endif
	}
	static CDuiString OpenSelectedDirDialog(HWND hWnd, LPCTSTR defaultPath, LPCTSTR title)
	{
		TCHAR file[MAX_PATH] = _T("");

		BROWSEINFO bif = { 0 };
		bif.hwndOwner = hWnd;
		bif.lpszTitle = title;
		bif.pszDisplayName = file;
		bif.ulFlags = BIF_BROWSEINCLUDEFILES;

		LPITEMIDLIST pidl;
		SHPathToPIDL(defaultPath, &pidl);
		bif.pidlRoot = pidl;
		bif.lParam = NULL;

		if (LPITEMIDLIST pil = SHBrowseForFolder(&bif)) {
			SHGetPathFromIDList(pil, file);
			return file;
		}
		return _T("");
	}

	static HRESULT SHPathToPIDL(LPCTSTR szPath, LPITEMIDLIST* ppidl)
	{
		LPSHELLFOLDER pShellFolder = NULL;
		OLECHAR wszPath[MAX_PATH] = {0};
		ULONG nCharsParsed = 0;

		StrCpy(wszPath, szPath);

		// Get an IShellFolder interface pointer
		HRESULT hr = SHGetDesktopFolder(&pShellFolder);
		if (FAILED(hr))
			return hr;
		
		// Convert the path name to Unicode
		//MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, -1, wszPath, MAX_PATH);

		// Call ParseDisplayName() to do the job
		//hr = pShellFolder->ParseDisplayName(NULL, NULL, wszPath, &nCharsParsed, ppidl, NULL);
		hr = pShellFolder->ParseDisplayName(NULL, NULL, wszPath, &nCharsParsed, ppidl, NULL);

		// Clean up
		pShellFolder->Release();
		return hr;
	}
};
	*/